package me.zk.practice1.hw;

import java.util.Scanner;

/**
 * 路灯照明问题
 * @author zhangkai
 * @date 2023/8/3 11:10
 */
public class S4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = "";
        while (scanner.hasNext()) {
            System.out.println("输入路灯数量:");
            int n = scanner.nextInt();
            if(n < 2) {
                return;
            }
            System.out.println("输入灯罩距离:");
            scanner = new Scanner(System.in);
           s = scanner.nextLine();
        }

        String[] nums = s.split(",");
        int l1 = 0;
        int l2 = 1;
        int len = 0;
        while (l2 < nums.length) {
            len += (Integer.parseInt(nums[l1]) + Integer.parseInt(nums[l2])- 100);
            l1++;
            l2++;
        }
        if (len < 0) {
            System.out.println("无法找到照到的距离为:" + Math.abs(len));
        }

    }
}
